package com.nondo.dean.saprfc.controller;

import com.nondo.dean.common.annotation.ApiVersion;

import com.nondo.dean.common.web.View;
import com.nondo.dean.saprfc.domain.OrderStatusTrackingResult;
import com.nondo.dean.saprfc.service.CrmOrderStautsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaofan
 * @Description:
 * @throws
 * @date 2018-04-2517:29
 * @Version 0.1
 */
@RestController
@RequestMapping("/{v}/saprfc/order")
public class CrmOrderStatusController {

    @Autowired
    CrmOrderStautsService crmOrderStautsService;

    /**
     * 返回sap的订单状态数据 暂时没用
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/status")
    public View<List<OrderStatusTrackingResult>> getSapOrderStatus(@RequestBody String sapCode){
        View<List<OrderStatusTrackingResult>> view =new View<>();
        List<OrderStatusTrackingResult> list=crmOrderStautsService.getOrderStatus(sapCode,"");
        view.setData(list);

        return view;
    }


    /**
     * 手动调用
     * sap返回的订单状态 更新app的订单状态
     * @return
     */
    @ApiVersion(1)
    @RequestMapping("/update/order/status")
    public void updateOrderStauts(){
     crmOrderStautsService.updateAppOrderStauts(null);

    }

}
